Skip to main content
POST
/
functions
[beta] Create a Function.
curl --request POST \
  --url https://api.samsara.com/functions \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "config": {
    "handler": "index.handler",
    "isScheduleEnabled": false,
    "params": {
      "region": "us-west",
      "threshold": "100"
    },
    "secrets": {
      "API_KEY": "my-secret-value"
    }
  },
  "name": "my-function",
  "description": "Processes incoming telemetry data."
}
'
{
  "data": {
    "codePackage": {
      "status": "deployed",
      "downloadGetUrl": "https://example.com/download?token=..."
    },
    "config": {
      "handler": "index.handler",
      "isScheduleEnabled": false,
      "params": {
        "Architecto sed delectus alias molestiae iure.": "Ut dolorem.",
        "Doloribus maiores et inventore neque nemo voluptatem.": "Nemo et delectus ab est."
      },
      "secrets": {
        "Qui aut voluptas.": "Et quia corrupti deserunt molestiae est."
      },
      "schedule": {
        "entries": [
          {
            "daysOfWeek": [
              false,
              true,
              true,
              true,
              true,
              true,
              false
            ],
            "timeSinceMidnightMs": 32400000
          }
        ],
        "timezone": "America/Los_Angeles"
      }
    },
    "createdAtTime": "2021-01-01T00:00:00Z",
    "effects": {
      "nextScheduledAtTime": "2021-01-01T00:00:00Z"
    },
    "lastUpdateTimestampMs": 1609459200000,
    "name": "my-function",
    "updatedAtTime": "2021-01-01T00:00:00Z",
    "uploadPutUrl": "https://example.com/upload?token=...",
    "description": "Processes incoming telemetry data."
  }
}

Documentation Index

Fetch the complete documentation index at: https://samsara-showcase.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json

Request body for creating a Function.

config
object
required

Configuration for the new Function.

name
string
required

Unique name for the Function.

Example:

"my-function"

description
string

A description of the Function.

Example:

"Processes incoming telemetry data."

Response

OK response.

data
object
required

Details of a newly created Function, including a URL for uploading the code package. After uploading, call the deploy endpoint to make the function runnable.